﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using log4net;
using log4net.Config;

namespace Trade.Library.Logs
{
    /// <summary>
    /// 
    /// </summary>
    public  class Log4NetLogFactory : LogFactoryBase
    {
        /// <summary>
        /// 实例化一个新的 <see cref="Log4NetLogFactory"/> 实例.
        /// </summary>
        public Log4NetLogFactory()
            : this("log4net.config")
        {

        }

        /// <summary>
        /// 通过制定的Config文件实例化一个新的 <see cref="Log4NetLogFactory"/> 实例.
        /// </summary>
        /// <param name="log4netConfig">config文件</param>
        public  Log4NetLogFactory(string log4netConfig)
            : base(log4netConfig)
        {
            log4net.Config.XmlConfigurator.Configure(new FileInfo(ConfigFile));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public  override ILog GetLog(string name)
        {
            return (ILog)new Log4NetLog(LogManager.GetLogger(name));
        }
    }
}
